Embedded Programming is the routine of installing hardware to run various pre-programmed functions that contribute to the completion and functionality of a product. This can be done on a number of hardware, but there are generally a few things to consider, that being:

  • Script/Programming
  • These impact the entire circuit in a product in their own way, each needing an equal amount of attention and reviewing for the circuit to function, and hence they will be covered in more detail.



    Electrical Components

    Electrical Components, alternatively referred to as Electronic Components are devices that use electricity.
    These can include and are not limited to:

    Electrical Components can be identified by one of two ways, one being their physical appearance or their electronic symbols, as shown below.

    Physical Appearance


    Electronic Symbols


    Electronic Symbols can be used to represent electronic circuits, and can be translated manually or electronically into a physical circuit.

    Current, Voltage and Resistance

    Electricity is the flow of electricity in a closed circuit. Current, Voltage and Resistance are measurements of various parts of a circuit's calculations. When setting up a circuit, current, voltage, and resistance should always be taken into consideration.
    Some formulas commonly used to calculate each of these variables are:

    Programming

    Embedded Programming is derived from the desire to reduce the number of devices in the circuit and the sizes. Originally, a dedicated computer system with dedicated functions were needed to perform specific tasks, but due to this goal of reducing the size, through the development of the Uno, the circuit was reduced to a single Intergrated Circuit with support devices.


    This IC and its programming is collectively known as Arduino. An Arduino system comprises of: With all of this information, it is ezsy to accidentally draw some misconceptions and mistake somee rumours for actual information. While there may be many miconceptions to cover and debunk, here are some common ones: With all this in mind, why should you use Arduino? It is a system made to emulate the capabilities of their larger and more specialised equivalents, but ultimately, it is a system that is made to do what those systems can do. With all of these incentives to use Arduino, it might be hard to decide which piece of hardware you should use. In those cases, you should refer to the various capabilities of each board according to what you need or want. However, in the case of this module, we are learning to use an Arduino Uno.

    Arduino Uno

    After you choose your board, you will then need to learn how to program with the Arduino IDE. In the case of the Uno, The general workflow of using the Arduino IDE would be:
    1. Write your code.

    2. Compile/Verify your code.

    3. Upload your code to UNO board.

    4. Press Reset Button, which rather than resetting all data on the board, actually runs the board starting from the first line of code.

    5. Observe Results and make changes if and where needed.

    This workflow can more or less be observed throughout all the variations of the UNO, as expected when something is open source. The programming and usage are mostly the same with some minor variations from one board to another, but their I/O Ports are largely the same. The only real different would be in the cost of each board.

    All of this software can be found on the Arduino Site, and the latest version should be the one to be used, with the most updated one as of the time of updating this site being 1.8.12. The Arduino IDE software is available in different platforms, with many resources and help available to users through a simple search.

    The UNO boards require drivers, which for the most part, are the FTDI drivers for original boards, and the CH340 drivers for cheaper boards, which need to be installed. The how-to can be checked online with help from google, but a guide I found useful can be found here.

    After downloading the neccessary software, you will now need to know how to use the Arduino IDE. Generally the set up should follow this order:
    1. Firstly, you need to connect your UNO board to the computer running the Arduino IDE.

    2. Launch the Arduino IDE.

    3. Setup the IDE.

    4. Select the correct board that you are using, but in this case, the board should be the Arduino UNO.

    5. Identify and check the port the board is connected to.

    With this done, you should be clear to write programs, from which you can follow the earlier progression when writing programs, which are called "Sketches", with the extension of ".ino". You can load the example program "Blink" to test this out.


    However, if you wish to write your own program, you will need to understand the functions of each section of the code, primarily, the the setup, loop, and Digital Input/Output.

    Setup()

    Loop()

    Things to keep in mind when programming:

    Digital Input/Output(I/O)

    Electronic Protoyping

    Electronic Prototyping involves using knowledge of electrical components and electricity to create a prototype, serving as an early sample or mockup of the project.
    This allows for testing and odifications to the design as the user sees fit, and can be done with three techniques.



    Breadboarding

    Breadboarding is a a technique that makes use of a breadboard, a construction base for prototyping electronics.

    Breadboarding


    Advantages:

    Disadvantages: Breadboarding Tools:

    Breadboard

    Power Rails Connector

    Dupont Male-Male Jumper Wires



    Stripboarding

    Stripboardng involves the use of an electronics protoyping board which provides a grid for placement and connectivity of components.

    Stripboarding


    Advantages:

    Disadvantages: Stripboarding Boards:

    Veroboard

    Stripboard ( holes only )

    Stripboard ( strips )

    Veroboard is the most common prototype board, requiring some skill, soldering, and tools, but stabled designs can be built, tested, and used.

    Printed Circuit Boards

    Printed Circuit Boards are boards that connect electronic components using copper tracks, with the components being soldered onto the PCB.
    These PCBs can be single, double, or multi-layered, with each "layer" referring to the conductive copper substrate layer(s) used on the board. These boards are made through two processes, chemical etching and mechanically engraved boards. Generally, Mechanically engraved boards are recommended for prototyping over chemical etched boards due to the toxicity of the latter's manufacturing process.



    Exercise: Wire and interface one input device and output device to read inputs from the input device to trigger the output device.

    With this exercise in mind, I decided to use a micro servo motor as my output device, and two push buttons as my input. The goal would be to make a servo that constantly turned, and using the buttons, someone would be able to control the speed of the buttons.
    So, I started off by declaring variables to be used in the code, then putting in the setup code, and finally the loop code.

    However, an error with the code popped up, saying that I was not allowed to lock buttons using boolean variables in the loop function. Hence, my fix to the solution was to create a function to unlock the buttons when both buttons were not pressed.
    And just when I thought I'd fixed the problem, I realised that there was a problem with the timing, and hence, due to not wanting to spend any more time on the exercise, changed it to a servo that turns 10 degrees in any direction when the corresponding button is pressed, resulting in this script.

    #include <Servo.h>
    
    bool pressed1 = false; // Used to detect if Button 1 was already pressed
    bool pressed2 = false; // Used to detect if Button 2 was already pressed
    int servoPin = 9; // Used to initialise the pin the servo is connected to.
    int pwr1 = 0; // Used to power button 1
    int pwr2 = 0; // Used to power button 2
    Servo servo; // Declaring servo unit
    int turnSpeed = 90;// sets angle of the motor
    bool lockState = false; // Buttons are unlocked.
    
    void setup()
    {
      // put your setup code here, to run once:
      pinMode(4,INPUT); // Initialise pin 4 for Button 1
      pinMode(5,INPUT); // Initialise pin 5 for button 2
      pinMode(servoPin,OUTPUT); // Initialise servo pin
      digitalWrite(4,HIGH); // Initialise button1 press
      digitalWrite(5,HIGH); // Initialise button2 press
      servo.attach(9);
      servo.write(turnSpeed);
    }
    
    void loop()
    {
      // put your main code here, to run repeatedly:
      pwr1 = digitalRead(4); // Assigning values to button 1
      pwr2 = digitalRead(5);// Assigning values to button 2
      
      // This section is used to handle inputs from the buttons
      if(pwr1==LOW && pressed1==false) // If button 1 is pressed once and is not locked
      {
        pressed1 = true; // Lock Button 1 to prevent spam
        pressed2 = true; // Lock Button 2 to prevent spam
        lockState = true; // Buttons are locked
        turnSpeed = turnSpeed - 10;// increase turn speed by lowering delay 
        servo.write(turnSpeed); // turn to new position
      }else if(lockState==true) // If button 1 and 2 is let go and buttons are still locked
      {
        Unlock();
      }
      
      if(pwr2==LOW && pressed2==false) // If button 2 is pressed and is not locked
      {
        pressed1 = true; // Lock Button 1 to prevent spam
        pressed2 = true; // Lock Button 2 to prevent spam
        lockState = true; // Buttons are locked
        turnSpeed = turnSpeed + 10; // decrease turn speed by increasing delay
        servo.write(turnSpeed); // turn to new posiiton
      }else if(lockState==true) // If button 1 and 2 is let go and buttons are still locked
      {
        Unlock();
      }
    }
    
    void Unlock()
    {
      pressed1 = false; // Unlock Button 1
      pressed2 = false; // Unlock Button 2
      lockState = false;
    }
    
    


    Next, I had to wire up a model to test if it would work, and hence, I used TinkerCAD, a website for making simulations of projects and found a similar circuit as reference. It can be found by clicking here.

    The simulation I made can be found here: Simulation

    Now that the simulation was wired up, I needed to make the physical version by wiring components on a breadboard, and it looks like this:

    Shown below is a video of the result.

    Click this if your video does not appear to download.

    Back to Index